package com.gx.mxbbx.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gx.mxbbx.dao.MedicalMapper;
import com.gx.mxbbx.po.Area;
import com.gx.mxbbx.po.Medical;
import com.gx.mxbbx.service.MedicalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.sql.Timestamp;
import java.util.List;

@Service
@Transactional
public class MedicalServiceImpl implements MedicalService {
    @Autowired
    private MedicalMapper medicalMapper;

    public PageInfo<Medical> getmedicalList(String medicalName, Integer currentPage, Integer limit) {
        PageHelper.startPage(currentPage, limit);
        List<Medical> list = medicalMapper.getmedicalList(medicalName);
        PageInfo<Medical> pageInfo = new PageInfo<Medical>(list);
        return pageInfo;
    }

    public void medicaladd(Medical medical) {
        medical.setCreateTime(new Timestamp(System.currentTimeMillis()));
        medical.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        medicalMapper.medicaladd(medical);
    }

    public Medical openmedicalEdit(Integer id) {
        Medical medical = medicalMapper.openmedicalEdit(id);
        return medical;
    }

    public void medicaledit(Medical medical) {
        medical.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        medicalMapper.medicaledit(medical);
    }

    public void medicaldelete(Integer id) {
        medicalMapper.medicaldelete(id);
    }
}
